% Function:
%   calculate the covariance of x and y
% Argument:
%   x: data x(vector)
%   y: data y(vector)
% Return:
%   r: covariance
function r = cova(x, y)
    if ~isvector(x) || ~isvector(y)
        error('x, y must be vector');
    end

    m = numel(x);
    if (numel(y) ~= m)
        error('length of x, y must be same');
    end

    r = sum((x - mean(x)) .* (y - mean(y))) / (m - 1);
end
